<template>
  <div class="login-page">
    <van-nav-bar title="账号登录"  left-arrow class="gree" @click-left="$router.go(-1)"/>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        placeholder="请输入账号"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        placeholder="请输入密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button block type="info" native-type="submit">登录</van-button>
      </div>
      <div class='footer'>
        <router-link class="link" to="/user">还没有账号,去注册~</router-link>
      </div>
    </van-form>
  </div>
</template>

<script>
import {userLog} from '@/api/user'
export default {
  name: "login-page",
  data() {
    return {
      username: "admin",
      password: "123456",
    };
  },
  methods: {
      async  onSubmit(values) {
      console.log("submit", values);
      const data = await userLog(values);
      this.$toast.success('登录成功');
      this.$router.push('/article')
      console.log(data);
    },
  
  },
};
</script>

<style lang="less" scoped>
.link {
  color: rgb(126, 116, 116);
  font-size: 12px;
  padding-right: 20px;
  
}
.footer {
  text-align: center;

}
.gree {
  background-color: rgb(103, 190, 103);
  color: aliceblue !important;
}
 /deep/.van-nav-bar__title {
  color:white;
}
 /deep/.van-icon-arrow-left {
  color: white !important;
}
</style>
